package tt.dz.appserver.dao.ext;

import java.util.List;

import org.springframework.stereotype.Repository;

import tt.dz.appserver.dao.base.BasisDao;
import tt.dz.appserver.entity.model.ChargerReserve;
import tt.dz.appserver.util.Constants;


/**
 * 电桩预约操作Dao
 * @author Administrator
 *
 */
@Repository
public class ChargerReserveDao extends BasisDao<ChargerReserve>{

	@Override
	public int update(ChargerReserve obj) {
		return super.update(obj);
	};
	
	/**
	 * 获取预约列表
	 * @param pageNo
	 * @return
	 */
	public List<ChargerReserve> findReserveList(Integer pageNo){
		
		ChargerReserve chargerReserve = new ChargerReserve();
		chargerReserve.setValid_flag(1);
		return super.findExample(chargerReserve, pageNo, Constants.PAGE_SIZE, "begin_time", 0);
	}
	
	/**
	 * 通过预约流水号码获取预约记录
	 * @param reservationSn
	 * @return
	 */
	public ChargerReserve findReservedByReservationSn(String reservationSn){

		//设置预约ID（流水号码）
		ChargerReserve chargerReserve = new ChargerReserve();
		chargerReserve.setReserve_id(reservationSn);
		List<ChargerReserve> reservesList = super.findExample(chargerReserve);
		if(reservesList.size()>0){
			return reservesList.get(0);
		}
		return null;
	}
}


